<template>
	<q-search v-model="searchParams" :config="searchConfig" />
</template>
<script setup lang="ts">
	import { ref } from 'vue';

	const searchForm = [
		{
			componentType: 'text',
			key: 'channelName',
			label: '输入框：',
		},
		{
			componentType: 'select',
			key: 'channelName1',
			label: '选择器：',
			options: [
				{
					value: '1',
					label: '渠道名称1',
				},
			],
		},
		{
			componentType: 'select-v2',
			key: 'channelName2',
			label: '虚拟列表选择器：',
			options: [
				{
					value: '2',
					label: '渠道名称2',
				},
			],
		},
		{
			componentType: 'checkSelect',
			selectAll: true,
			key: 'channelName3',
			label: 'checkBox选择器：',
			options: [
				{
					value: '3',
					label: '渠道名称3',
				},
			],
		},
		{
			componentType: 'cascader',
			key: 'channelName4',
			label: '级联选择器：',
			options: [
				{
					value: '4',
					label: '渠道名称4',
					children: [
						{
							value: '4-1',
							label: '渠道名称4-1',
						},
						{
							value: '4-2',
							label: '渠道名称4-2',
							children: [
								{
									value: '4-2-1',
									label: '渠道名称4-2-1',
								},
							],
						},
					],
				},
			],
		},
	];

	const searchParams = ref({});
	const searchConfig = ref({
		labelWidth: 105,
		handlerSearch({ params, type }) {
			/**
			 * params: 搜索项 绑定值
			 * type: 按钮类型 searchForm：搜索按钮  resetForm：重置按钮
			 */
			console.log(params, type);
		},
		downLoadButtonText: '下载',
		handleDownLoad(params) {
			return new Promise(async (resolve, reject) => {
				// try {
				//   let exportParams = {
				//     ...tableConfig.searchParams,
				//   };
				//   const { data } = await downloadTeamLevelAward(
				//     qs.stringify(exportParams)
				//   );
				//   downloadFile(data, "团队等级奖对账" + $dateFormat.YYYYMMDD(Date.now()));
				//   resolve(false);
				// } catch (error) {
				//   resolve(false);
				// }
			});
		},
		// 配置表头内容
		formConfigList: searchForm,
	});
</script>
